package com.ssy.lingxi.logistics.repository;

import com.ssy.lingxi.logistics.entity.ShipperAddress;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.util.List;

/**
 * 发货地址实体仓库
 * @author yzc
 * @version 2.0.0
 * @date 2020/7/13
 */
public interface ShipperAddressRepository extends JpaRepository<ShipperAddress, Long>, JpaSpecificationExecutor<ShipperAddress> {

    Page<ShipperAddress> findAllByMemberIdAndRoleId(Long memberId, Long roleId, Pageable page);

    List<ShipperAddress> findAllByMemberIdAndRoleId(Long memberId, Long roleId, Sort sort);

    List<ShipperAddress> findAllByIsDefaultAndMemberIdAndRoleId(Integer isDefault, Long roleId, Long memberId);

    ShipperAddress findByIdAndMemberIdAndRoleId(Long id, Long roleId, Long memberId);

    Page<ShipperAddress> findByMemberIdAndRoleIdAndShipperNameContains(Long memberId, Long roleId, String name, Pageable pageable);

    ShipperAddress findByStoreIdAndMemberIdAndRoleId(Long storeId, Long memberId, Long roleId);

    void deleteByStoreIdAndMemberIdAndRoleId(Long storeId, Long memberId, Long roleId);

    List<ShipperAddress> findAllByMemberIdAndRoleIdAndIsStore(Long memberId, Long roleId, Integer isStore, Sort sort);

    List<ShipperAddress> findAllByMemberIdAndRoleIdAndStoreStatus(Long memberId, Long roleId, Integer storeStatus, Sort sort);
}